<layout name='layout/main' />

	<header class="am-header am-header-default">
		<div class="am-header-left am-header-nav">
		<a href="<{:U('Index/index')}>"><i class="am-header-icon am-icon-home"></i></a>
    	</div>
		<h1 class="am-header-title"><{$cate.name}></h1>
		<div class="am-header-right am-header-nav">
		<a href="javascript:window.history.go(-1)"><i class="am-header-icon am-icon-reply"></i></a>
    	</div>
	</header>


	<form id="search_form" name="search_form" enctype="multipart/form-data" action="<{:U('Store/search')}>" method="post">
		<div class="m-l-search">
			<input id="s" class="inp-search" name="s" type="search" value="" placeholder="输入关键字搜索">
			<input class="btn-search" name="search-btn" type="submit" value="搜索">
		</div>
	</form>

	
	<div class="m-select c666 order_control">
		<span><a href="javascript:" order="time">时间<i><em></em></i></a></span>
		<span><a href="javascript:" order="sellNumber">销量<i><em></em></i></a></span>
		<span><a href="javascript:" order="price" class="arrow-down">价格<i><em></em></i></a></span>
	</div>

	<ul id="m_list" class="m-list">
	<volist name="list" id="vo">
	<li>
		<span class="pic">
			<a href="<{:U('Store/view',array('id'=>$vo['id'],'cid'=>$vo['cid']))}>">
				<img class="am-img-responsive" src="<{$vo.picname}>" data-original="<{$vo.picname}>">
			</a>
		</span>
		<span class="con">
			<a class="t" href="<{:U('Store/view',array('id'=>$vo['id'],'cid'=>$vo['cid']))}>"><{$vo.name}></a>
			<eq name="vo.baoxian" value="1">
			<div>送全年交强险</div>
			</eq>
			<b>￥<{$vo.price}></b><del>￥<{$vo.shichang}></del>
			<span><{$vo.sellNumber}>人付款</span>
		</span>
		<div class="clear"></div>
	</li>	
	</volist>
	</ul>

	<div class="show-more" id="show_more" page="2" style="display:none"><i class="am-icon-spinner am-icon-pulse"></i> 数据加载中...</div>

<input type="hidden" value="1" id="pageid" />
<input type="hidden" id="canScroll" value="1" />
<script>
var action="<{$action}>";
var s="<{$s}>";
$(function(){
	$('#search_form').submit(function() {
		var s= $('#s').val();
		if (s == '') {
			floatNotify.simple('请输入搜索关键词');
			return false;
		}
	});

	//点击排序
	var base_url = '/index.php?g=Wap&m=Store&a='+action+'&cid=<{$cate.id}>',
		method = 'DESC',
		_get_method = '<{$method}>',
		order = 'time',
		_get_order  = '<{$order}>';
	if (_get_order != '') {
		order = _get_order;
	}
	$('.order_control a').removeClass('arrow-down');
	if (_get_method == 'DESC')  {
		method = 'ASC';
		$('.order_control a[order="' + order + '"]').addClass('arrow-down');
	} else {
		$('.order_control a[order="' + order + '"]').addClass('arrow-up');
	}
	$('.order_control a').click(function() {
		var order = $(this).attr('order');
		var url = base_url + '&order=' + order+'&method='+method;
		location.href = url;
	});
	
	/*---------------------加载更多--------------------*/
	if(s!=''){
		var b_url = '/index.php?g=Wap&m=Store&a=ajaxProducts&keys='+encodeURI(s)+'';
	}else{
		var b_url = '/index.php?g=Wap&m=Store&a=ajaxProducts';
	}
	var total = <{$total}>,
		pagesize = 8,
		pages = Math.ceil(total / pagesize);
	var com_link = '/index.php?g=Wap&m=Store&a=view';
	if (pages > 1) {
		var _page = $('#show_more').attr('page');
		$(window).bind("scroll",function() {
			if ($(document).scrollTop() + $(window).height()+100 >= $(document).height()) {
				$('#show_more').css({"display":"block"}).html('<i class="am-icon-spinner am-icon-pulse"></i> 数据加载中');
				if (_page > pages) {
					$('#canScroll').attr('value',0);
					$('#show_more').hide().html('<i class="am-icon-spinner am-icon-pulse"></i> 数据加载中');
					return;
				}
				if($('#canScroll').val()==0){//不要重复加载
					return;
				}
				$('#canScroll').attr('value',0);
				$.ajax({
					type : "GET",
					data : {'page' : _page,'cid':<{$cate.id}>, 'inajax' : 1},
					url :  b_url + '&order=' + order + '&method=' + _get_method + '&pagesize='+pagesize,
					dataType : "json",
					success : function(RES) {
						$('#canScroll').attr('value',1);
						$('#show_more').hide().html('<i class="am-icon-spinner am-icon-pulse"></i> 数据加载中');
						data = RES.message;
						if(data.length>0){
							$('#show_more').attr('page',parseInt(_page)+1);
						}
						_page = $('#show_more').attr('page');
						var _tmp_html = '';						
						$.each(data, function(x, y) {
							_tmp_html +=    '<li><span class="pic">' +
							'<a href="' + com_link + '&id=' + y.id + '&cid='+y.cid+'">' +
							'<img src="' +y.picname + '" />' +
							'</a></span><span class="con"><a class="t" href="' + com_link + '&id=' + y.id + '&cid='+y.cid+'">' + y.name + '</a><b>￥'+ y.price +'&nbsp;元</b><del>￥' + y.shichang + '</del>' +
							'<span>' + parseInt(y.sellNumber) + '人付款</span></span></li>';
						});
						$('#m_list').append(_tmp_html);
					}
				})
			}
		});
	}
});
</script>

<div class="footerBox">
	<include file="Public:menu" />
</div>

	